package com.zhuhjay.service.system.model.domain;

import com.zhuhjay.common.base.util.BeanBuilder;
import com.zhuhjay.service.system.model.entity.SystemDir;
import lombok.Data;

import java.util.Date;

/**
 * @author ZhuHJay
 * @date 2023/3/29 14:44
 */
@Data
public class FolderInfo {

    private String id;
    private String name;
    private String parentFolder;
    private String createUser;
    private Date createTime;

    private String power;

    /**
     * 将 SystemDir 转换为 FolderInfo
     *
     * @param dir SystemDir
     * @return FolderInfo
     */
    public static FolderInfo copyTo(SystemDir dir, String username) {
        return BeanBuilder.builder(FolderInfo::new)
                .with(FolderInfo::setId, dir.getId())
                .with(FolderInfo::setName, dir.getName())
                .with(FolderInfo::setParentFolder, dir.getParentId())
                .with(FolderInfo::setCreateUser, username)
                .with(FolderInfo::setCreateTime, dir.getCreateTime())
                .with(FolderInfo::setPower, dir.getPower())
                .build();
    }

}
